<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>


<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>用户管理</title>
<link rel="stylesheet" href="../css/common.css" type="text/css" />
<script type="text/javascript" src="http://static.mttang.com/js/jquery-1.4.2.min.js"></script>
</head>



<script type="text/javascript">
function sel(userId,userName){
	var depId = $("#depId").val();
	var action = $("#action").val();
	
	
	
	
	if(action=='setLeader'){//指派
			var url = "<%=basePath%>dept/dept.do?prv=query&method=setDepLeader&depId="+depId+"&userId="+userId+"&userName="+encodeURIComponent(userName);
			//alert(url);
			$.post(url,null,function(data){
				if(data=='0'){
					alert('指派成功');
					window.opener.document.getElementById("d_"+depId).innerHTML=userName;
					var selUserURL = "<%=basePath%>user/user.do?method=query&prv=query&action=updateLeader&depId="+depId;
					window.opener.document.getElementById("ac_"+depId).innerHTML="<a href='#' onclick=\"update('"+selUserURL+"');\">修改</a>";
					window.close();
				}else{
					alert('系统错误');
					window.close();
				}
			});
			
	}else if(action=='updateLeader'){//修改
			var url = "<%=basePath%>dept/dept.do?prv=query&method=updateDepLeader&depId="+depId+"&userId="+userId+"&userName="+encodeURIComponent(userName);
			
			$.post(url,null,function(data){
				if(data=='0'){
					alert('修改成功');
					window.opener.document.getElementById("d_"+depId).innerHTML=userName;
					window.close();
				}else{
					alert('系统错误');
					window.close();
				}
			});
	}
}

</script>


<body>
<div id="man_zone" align="left">
<center><c:out value="${message}" /></center>
<form id="form1" name="form1" method="post"
	action="user.do?method=query">
<table class="table_qry" border="0" cellpadding="3" cellspacing="1">
	<tr>
		<td>姓名</td>
		<td><input type="text" name="name" id="name" value='<c:out value="${name}"/>' /></td>
		<td>工号</td>
		<td><input type="text" name="empno" id="empno" value='<c:out value="${empno}"/>' /></td>
		<td>角色:</td>
            <td><select id="roleId" name="roleId">
        <option value="">请选择</option>
        	<c:if test="${rolelist != null}">
        		<c:forEach items="${rolelist}" var="role" varStatus="status">
        			<option value='<c:out value="${role.ROLE_ID}"/>'><c:out value="${role.ROLE_NAME}"/></option>
        		</c:forEach>
        	</c:if>
          </select></td>
		<td>
		<input type="hidden" name="prv" value="query" /> 
		<input type="hidden" id="action" name="action" value="<c:out value="${action }" />" /> 
		<input type="hidden" id="depId" name="depId" value="<c:out value="${depId }" />" /> 
		   <input type="submit" value="查询" />
		   </td>
		<td>
         </td>
	</tr>
</table>
<table class="table_style" width="99%" border="0" align="center"
	cellpadding="3" cellspacing="1">
	<tr>
		<th>选择</th>
	    <th>姓名</th>
	    <th>角色</th>
	    <th>工号</th>
	    <th>部门</th>
	    <th>状态</th>
	</tr>
	<c:forEach items="${bean.datas}" var="item" varStatus="status">
		<tr>
			<td class="table_text">
				<input type="checkbox" onclick="sel('<c:out value="${item.id}" />','<c:out value="${item.name}" />');" />
			</td>
			
			<td class="table_text"><c:out value="${item.name}" />
			</td>
			<td class="table_text"><c:out
				value="${item.roleName}" />
			</td>
			<td class="table_text"><c:out
				value="${item.empno}" />
			</td>
			<td class="table_text"><c:out
				value="${item.depName}" />
			</td>
			<td class="table_text">
			<c:if test="${item.state == 1}">正常</c:if>
			<c:if test="${item.state == -1}">删除</c:if>
			</td>
		</tr>
	</c:forEach>
	<tr>
		<td align="left" colspan="7" height="35" bgcolor="#FFFFFF"><!-- 页面隐藏域信息 -->
		<c:out value="${bean.fliper.formathtml}" escapeXml="false" /> <!-- 分页显示信息 -->
		<c:out value="${bean.footerhtml}" escapeXml="false" /></td>
	</tr>
</table>
</form>
</div>
</body>
</html>